<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>联程审核connectAdult.html</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<style>
		body{
			background:#f1f1f1;
			padding-bottom:20px;
		}
		.title{
			height:45px;
			line-height:45px;
			margin-left:4px;
			font-size:14px;
			font-weight:900;
			width:1032px;
		}
		.quare{
			margin:0 7px 0 11px;
			position:relative;
			top:3px;
			display:inline-block;
			width:16px;
			height:16px;
			background:url(../img/flightManage/addConnectflight.png) no-repeat;
		}
		.adultQuare{
			width:4px;
			background:#00aa98;
		}
		.lkcp{
			margin:0 7px 0 11px;
			position:relative;
			top:3px;
			display:inline-block;
			width:17px;
			height:14px;
			background:url(../img/flightManage/paTicked.png) no-repeat;
		}
		.pjzf_title{
			margin:0 7px 0 11px;
			position:relative;
			top:3px;
			display:inline-block;
			width:17px;
			height:17px;
			background:url(../img/flightManage/pjzf.png) no-repeat;
		}
		.contentBox{
			width:1032px;
			background:white;
			margin-left:14px;
		}
		.times{
			line-height:40px;
			margin-left:20px;
		}
		.content{
			padding-bottom:20px;
			padding-top:20px;
		}
		.content table{
			width:990px;
			margin-left:20px;
		}
		.content table th,td{
			height:30px;
			border:1px solid #e7e7e7;
		}
		.content table th{
			background:#f1f1f1;
		}
		.backButton{
			text-align:center;
			padding:20px 0 ;
		}
		.peopleTotal{
			display:inline-block;
			margin-left:20px;
			font-weight:normal;
		}
		.peopleTotal .totalPrice{
			color:red;
		}
		.head{
			line-height:45px;	
		}
		.btnBox{		
			text-align:center;
			margin-top:15px;
		}
		.cancel{
		background:#afb1b0;
		margin-left:10px;
		}
		table tbody input{
			font-family:"微软雅黑";
			width:100%;
			height:100%;
			border:none;
			text-align:center;
			outline:none;
		}
		.departureDate,.arriveAirportDate{
			text-align:left;
			margin-left:4px;
		}
	
	
		.audioMess{
			line-height:44px;
			margin-left:20px;
		}
		.audioMess span{
			position:relative;
			top:5px;
			margin-right:5px;
		}
		textarea{
			margin-left:10px;
			width:800px;
			height:100px;
			font-family:"微软雅黑";
			background:#fafafa;
			border:1px solid #e7e7e7;
		}
	    
	</style>
	<body>
	
		<p class='title'>
			<span><i class='quare'></i>联程航班</span>
		</p>
		<div class='contentBox'>
			<div class='content'>
				<table class="connectFlight">
					<tr>
						<th style="width:30px;">序号</th>
						<th>出发</th>
						<th style="display:none">出发三字码</th>
						<th>出发航站楼</th>
						<th>到达</th>
						<th style="display:none">到达三字码</th>
						<th>到达航站楼</th>
						<th>航班号</th>
						<th>舱位</th>
						 <th>机型</th> 
						<th>出发日期</th>
						<th>出发时间</th>
						<th>到达日期</th>
						<th>到达时间</th>
					</tr>
					<tbody class="clear">
											
					</tbody>
				</table>
			</div>
			
			<!-- 分页功能没未有添加 -->
		</div>
		<p class='title'>
			<span><i class='lkcp'></i>旅客与出票信息</span>
		</p>
		<div class='contentBox'>
			<div class='content' style='padding-top:20px;'>
				<table>
					<tr>	
						<th>成人</th>
						<th>儿童</th>
						<th>婴儿</th>
						<th style="display:none;"></th>
					</tr>
					<tbody class="clearPassenger">
						<tr>
							<td class="adultPassenger"></td>
							<td class="childPassenger"></td>
							<td class="infantPassenger"></td>
							<td class="connectId" style="display:none;"></td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		<p class='title'>
			<span><i class='pjzf_title'></i>票价与支付</span>
			<span class='peopleTotal'>总费用：<span id="audlt" class="totalPrice"></span><span class="quoteCurrency"></span></span>
		</p>
		<div class='contentBox'>
			<div class='content' style='padding-top:20px;'>
				<table>
					<tr>
						<th>旅客类型</th>
						<th>票价</th>
						<th>税金</th>
						<th>总费用(单人)</th>
						<th>旅客人数</th>
						<th>总费用</th>						
					</tr>
					<tbody class="pjzf">
						<tr>
							<td>成人</td>
							<td><input type="text" class="adultPrice"></td>
							<td><input type="text" class="adultTFC"></td>
							<td class="adultSigleprice"></td>
							<td class="adultNum"></td>
							<td class="adultTotalprice"></td>
						</tr>
						<tr>
							<td>儿童</td>
							<td><input type="text" class="childPrice"></td>
							<td><input type="text" class="childTFC"></td>
							<td class="childSigleprice"></td>
							<td class="childNum"></td>
							<td class="childTotalprice"></td>
						</tr>
						<tr>
							<td>婴儿</td>
							<td><input type="text" class="infantPrice"></td>
							<td><input type="text" class="infantTFC"></td>
							<td class="infantSigleprice"></td>
							<td class="infantNum"></td>
							<td class="infantTotalprice"></td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
		 <!-- 合同审核信息 -->
		 <p style='padding:8px 0;' class='title'>
			<span><i class='quare adultQuare'></i>合同审核信息</span>
		</p>
		<div class='contentBox' style="padding-top:20px; padding-bottom:20px;">
			<p class='audioMess'>审核结论 ：<span><input checked value="1" type='radio' name='choose'/></span>通过<span><input style="margin-left:10px;" value="0" type='radio' name='choose' /></span>不通过</p>
			<p style='margin-left:20px;display:inline-block;vertical-align:top'>审核意见 <span style="color:#aaaaaa;">(300字以内)</span></p>
			<textarea class='reason'></textarea>		
		</div>
		 
		<div class='btnBox'>
			<button class='Dolo_btn sure'>确认</button>
			<button class='Dolo_btn cancel'>取消</button>
		</div>  
	</body>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../js/jquery.autocomplete.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
			<!-- 引入my97日期时间控件 -->
		<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js" charset="utf-8"></script>	
		<script type="text/javascript" src="../js/common.js" ></script>
		<script>
		$(".cancel").click(function(){
			closeWin();
		});
		 var url = document.location.href.toString();
		 var u = url.split("=");
		 var quoteCurrency = parent.$(".baojiaCurrency").text();
		 $(".quoteCurrency").text(commomFun.currencyMStr(quoteCurrency));
		// alert(u[1]);// 获取通过URL向下一个页面传过来的id值
		//展示联程航班、旅客信息、票价支付信息
		$.ajax({
			type:"get",
			url:"../order/"+u[1]+"/getConnectOrder?temp="+Math.random(),
			dataType:"json",
			async:false,
			success:function(data){
				var itineraries=data.data.data.itineraries;
				var str = "";
				for(var i=0;i<itineraries.length;i++){
					/* $(".departureAirportCode").eq(i).text(itineraries[i].departureAirport+"("+itineraries[i].departureAirportCode+")");//出发
					$(".departureAirportTerminal").eq(i).text(itineraries[i].departureAirportTerminal);//出发航站楼
					$(".arriveAirportCode").eq(i).text(itineraries[i].arriveAirport+"("+itineraries[i].arriveAirportCode+")");//到达
					$(".arriveAirportTerminal").eq(i).text(itineraries[i].arriveAirportTerminal);//到达航站楼
					$(".flightNumber").eq(i).text(itineraries[i].flightNumber);//航班号
					$(".seatClass").eq(i).text(itineraries[i].seatClass);//舱位
					$(".aircraft").eq(i).text(itineraries[i].aircraft);//机型
					$(".departureDate").eq(i).text(itineraries[i].departureDate);//出发日期
					$(".departureTime").eq(i).text(itineraries[i].departureTime);//出发时间
					$(".arriveAirportDate").eq(i).text(itineraries[i].arriveAirportDate);//到达日期
					$(".arriveAirportTime").eq(i).text(itineraries[i].arriveAirportTime);//到达时间
					
					$(".Code1").eq(i).text(itineraries[i].departureAirportCode);//出发机场三字码隐藏
					$(".Code2").eq(i).text(itineraries[i].arriveAirportCode);//到达机场三字码隐藏 */
					str += '<tr>' +
								'<td class="index">'+(i+1)+'</td>' +
								'<td class="departureAirportCode">'+itineraries[i].departureAirport+'('+itineraries[i].departureAirportCode+')</td>' +
								'<td class="Code1" style="display:none">'+itineraries[i].departureAirportCode+'</td>' +
								'<td class="departureAirportTerminal">'+commomFun.toEmptyString(itineraries[i].departureAirportTerminal)+'</td>' +
								'<td class="arriveAirportCode">'+itineraries[i].arriveAirport+'('+itineraries[i].arriveAirportCode+')</td>' +
								'<td class="Code2" style="display:none">'+itineraries[i].arriveAirportCode+'</td>' +
								'<td class="arriveAirportTerminal">'+commomFun.toEmptyString(itineraries[i].arriveAirportTerminal)+'</td>' +
								'<td class="flightNumber">'+itineraries[i].flightNumber+'</td>' +
								'<td class="seatClass">'+itineraries[i].seatClass+'</td>' +
								'<td class="aircraft">'+commomFun.toEmptyString(itineraries[i].aircraft)+'</td>' +
								'<td class="departureDate">'+itineraries[i].departureDate+'</td>' +
								'<td class="departureTime">'+itineraries[i].departureTime+'</td>' +
								'<td class="arriveAirportDate">'+commomFun.toEmptyString(itineraries[i].arriveAirportDate)+'</td>' +
								'<td class="arriveAirportTime">'+itineraries[i].arriveAirportTime+'</td>' +
							'</tr>	'
					
				}
				$(".clear").append(str);
				$(".adultPassenger").text(data.data.data.adultPassengerNumber);//成人数量
				$(".childPassenger").text(data.data.data.childPassengerNumber);//儿童数量
				$(".infantPassenger").text(data.data.data.infantPassengerNumber);//婴儿数量
				$(".adultNum").text(data.data.data.adultPassengerNumber);//成人旅客人数
				$(".childNum").text(data.data.data.childPassengerNumber);//儿童旅客人数
				$(".infantNum").text(data.data.data.infantPassengerNumber);//婴儿旅客人数
				$(".connectId").text(data.data.data.id);//id
				$(".adultPrice").val(commomFun.toEmptyString(data.data.data.adultPrice));//成人票价
				$(".adultTFC").val(commomFun.toEmptyString(data.data.data.adultTFC));//成人税金
				$(".childPrice").val(commomFun.toEmptyString(data.data.data.childPrice));
				$(".childTFC").val(commomFun.toEmptyString(data.data.data.childTFC));
				$(".infantPrice").val(commomFun.toEmptyString(data.data.data.infantPrice));
				$(".infantTFC").val(commomFun.toEmptyString(data.data.data.infantTFC));								
			}
			
		})
		
		
		//封装函数将如果是空""转化为数字0
		function emptyTransZero(n){
			if(n==""||n==undefined||isNaN(n)){
				return Number("0");
			}else{
				return Number(n);
			}
			
		}
		var adultSigleprice=0;//成人总费用(单人)
			adultSigleprice=emptyTransZero($(".adultPrice").val())+emptyTransZero($(".adultTFC").val());
			$(".adultSigleprice").text(adultSigleprice.toFixed(2));
			$(".adultPrice,.adultTFC").keyup(function(){//成人总费用联动效果
				adultSigleprice=emptyTransZero($(".adultPrice").val())+emptyTransZero($(".adultTFC").val());
				adultSigleprice = adultSigleprice.toFixed(2)
				$(".adultSigleprice").text(adultSigleprice);
			});
			
		var childSigleprice=0;//儿童总费用(单人)
			childSigleprice=emptyTransZero($(".childPrice").val())+emptyTransZero($(".childTFC").val());
			$(".childSigleprice").text(childSigleprice.toFixed(2));
			$(".childPrice,.childTFC").keyup(function(){//儿童总费用联动
				childSigleprice=emptyTransZero($(".childPrice").val())+emptyTransZero($(".childTFC").val());
				childSigleprice = childSigleprice.toFixed(2);
				$(".childSigleprice").text(childSigleprice);
			});
			
			
		var infantSigleprice=0;//婴儿总费用（单人）
			infantSigleprice=emptyTransZero($(".infantPrice").val())+emptyTransZero($(".infantTFC").val());
			$(".infantSigleprice").text(infantSigleprice.toFixed(2));
			$(".infantPrice,.infantTFC").keyup(function(){//婴儿总费用联动
				infantSigleprice=emptyTransZero($(".infantPrice").val())+emptyTransZero($(".infantTFC").val());
				infantSigleprice=infantSigleprice.toFixed(2);	
				$(".infantSigleprice").text(infantSigleprice);
			});
			
		
		
		var adultTotalprice=0;//成人总费用
			adultTotalprice=emptyTransZero($(".adultPassenger").text())*adultSigleprice;
			$(".adultTotalprice").text(adultTotalprice.toFixed(2));
			$(".adultPrice,.adultTFC").keyup(function(){ //成人总费用联动
				adultTotalprice=emptyTransZero($(".adultPassenger").text())*adultSigleprice;
				adultTotalprice = adultTotalprice.toFixed(2);
				$(".adultTotalprice").text(adultTotalprice);
			});
			
		var childTotalprice=0;//儿童总费用
		childTotalprice=emptyTransZero($(".childPassenger").text())*childSigleprice;
		$(".childTotalprice").text(childTotalprice.toFixed(2));
		$(".childPrice,.childTFC").keyup(function(){ //儿童总费用联动
			childTotalprice=emptyTransZero($(".childPassenger").text())*childSigleprice;
			childTotalprice = childTotalprice.toFixed(2);
			$(".childTotalprice").text(childTotalprice);
		})
		
		var infantTotalprice=0;//婴儿总费用
		infantTotalprice=emptyTransZero($(".infantPassenger").text())*infantSigleprice;
		$(".infantTotalprice").text(infantTotalprice.toFixed(2));
		$(".infantPrice,.infantTFC,.infantPassenger").keyup(function(){ //婴儿总费用联动
			infantTotalprice=emptyTransZero($(".infantPassenger").text())*infantSigleprice;
			infantTotalprice = infantTotalprice.toFixed(2);
			$(".infantTotalprice").text(infantTotalprice);
		})
		
		var totalPrice=0;//总费用
		totalPrice=emptyTransZero(adultTotalprice)+emptyTransZero(childTotalprice)+emptyTransZero(infantTotalprice);
		$(".totalPrice").text(totalPrice.toFixed(2));
		$(".adultPrice,.adultTFC,.childPrice,.childTFC,.infantPrice,.infantTFC").keyup(function(){ //总费用联动
			totalPrice=emptyTransZero(adultTotalprice)+emptyTransZero(childTotalprice)+emptyTransZero(infantTotalprice);
			$(".totalPrice").text(totalPrice.toFixed(2));
		})
		
		
		
		$(".sure").click(function(){
			//对票价与支付的input输入框做不能为空的验证
			if($("input:radio[name='choose']:checked").val()=="1"){
			 var length_pjzf = $(".pjzf input[type=text]").length;
				for(var i=0;i<length_pjzf;i++){
					if($(".pjzf input[type=text]").eq(i).val()==""){
						layer.msg("票价与税金输入不能为空",{icon: 2,time:1000})
						return false;
					}
				}
			}	
			var auditStatus = $("input:radio[name='choose']:checked").val();//选中状态
			var auditMessage=$(".reason").val();//审核意见		
			var json={};//初始化对象，用于存放外层传输的数据
			//获取联程航班表格的数据
			var len=$(".connectFlight>.clear>tr").length;
			var flightDataArr=[];//定义数组用于存放每条数据
			
			for(var i=0;i<len;i++){
				var json_flight={};
				json_flight.index=parseInt($(".index").eq(i).text());//序号
				json_flight.departureAirportCode=$(".Code1").eq(i).text();//出发机场三字码
				json_flight.arriveAirportCode=$(".Code2").eq(i).text();//到达机场三字码
				
				//json_flight.departureAirportCode=$(".departureAirportCode").eq(i).val();//出发
				//json_flight.arriveAirportCode=$(".arriveAirportCode").eq(i).val();//到达
				json_flight.flightNumber=$(".flightNumber").eq(i).text();//航班号
				json_flight.seatClass=$(".seatClass").eq(i).text();//舱位
				json_flight.aircraft=$(".aircraft").eq(i).text();//机型
				json_flight.departureDate=$(".departureDate").eq(i).text();//出发日期
				json_flight.departureTime=$(".departureTime").eq(i).text();//出发时间
				json_flight.arriveAirportDate=$(".arriveAirportDate").eq(i).text();//到达日期
				json_flight.arriveAirportTime=$(".arriveAirportTime").eq(i).text();//到达时间
				json_flight.departureAirportTerminal=$(".departureAirportTerminal").eq(i).text(); //出发航站楼
				json_flight.arriveAirportTerminal=$(".arriveAirportTerminal").eq(i).text(); //到达航站楼
				flightDataArr.push(json_flight);
			}
			json.itineraries=flightDataArr;//联程航班表格的数据
			json.adultPrice=$(".adultPrice").val();//成人票价
			json.childPrice=$(".childPrice").val();//儿童票价
			json.infantPrice=$(".infantPrice").val();//婴儿票价
			json.adultTFC=$(".adultTFC").val();//成人税金
			json.childTFC=$(".childTFC").val();//儿童税金
			json.infantTFC=$(".infantTFC").val();//婴儿税金
			json.adultPassengerNumber=$(".adultPassenger").text();//成人的数量
			json.childPassengerNumber=$(".childPassenger").text();//儿童的数量
			json.infantPassengerNumber=$(".infantPassenger").text();//婴儿的数量	
			json.id=$(".connectId").text();//id
						
			//将得到的数据传输给服务器端
			
			layer.confirm('确定审核？', {
			  	btn: ['确定','取消'] //按钮
			}, function(){
			 	sure();	
			});
			function sure(){
				layer.load();
				$.ajax({
					type:"post",
					url:"../order/auditConnectOrder?auditStatus="+auditStatus+"&auditMessage="+auditMessage+"&temp="+Math.random(),
					contentType:'application/json;charset=utf-8',
					data:JSON.stringify(json),
					async:true,
					success:function(data){
						layer.closeAll('loading');
						var data=JSON.parse(data);						
						if(data.status.toString()=="1001"){
							layer.msg(data.message, {icon: 1,time:1000},function(){
								var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
								parent.layer.close(index);//关闭弹窗
							});			
						}else{							
							layer.msg(data.message, {icon: 2,time:1000})
						}
					}
				});			
			}			
		});
	 	

		
		
		</script>		
</html>
